{extend name="system@public:layout" /}
{block name="title"}销售量(额)排行{/block}
{block name="head"}
<script src="/public/plugins/jsAddress/jsAddress.js"></script>
{/block}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox">
        <div class="ibox-title">
            <div class="pull-left">
                <ol class="breadcrumb">
                    <li><i class="fa fa-hand-o-right"></i> 销售量(额)排行 TOP 100</li>
                </ol>
            </div>
            <div class="pull-right">
                <form class="form-inline" method="post" id="searchForm">
                    <input type="hidden" name="sort_field" value="{$query.sort_field}"/>
                    <input type="hidden" name="date_type" id="dateType" value="{$query.date_type}"/>
                    <div class="form-group">
                        <select name="area_id" id="areaId" class="form-control">
                            <option value="0-0">不限地区</option>
                            {volist name="area" id="vo"}
                            <option value="{$vo.id}-{$vo.pid}" {eq name="query.area_id" value="$vo['id'].'-'.$vo['pid']"}selected{/eq}>{$vo._name}</option>
                            {/volist}
                        </select>
                    </div>
                </form>
            </div>
            <div class="clearfix"></div>
        </div>
        <div class="ibox-content">
            <ul class="nav nav-tabs" id="tab_search">
                <li {eq name="query.date_type" value="0"}class="active"{/eq}><a href="javascript:;" onclick="$('#dateType').val(0);$('#searchForm').submit();">商品销售总排行</a></li>
                <li {eq name="query.date_type" value="1"}class="active"{/eq}><a href="javascript:;" onclick="$('#dateType').val(1);$('#searchForm').submit();">今日</a></li>
                <li {eq name="query.date_type" value="2"}class="active"{/eq}><a href="javascript:;" onclick="$('#dateType').val(2);$('#searchForm').submit();">本周</a></li>
                <li {eq name="query.date_type" value="3"}class="active"{/eq}><a href="javascript:;" onclick="$('#dateType').val(3);$('#searchForm').submit();">本月</a></li>
                <li {eq name="query.date_type" value="4"}class="active"{/eq}><a href="javascript:;" onclick="$('#dateType').val(4);$('#searchForm').submit();">本年度</a></li>
                <li {eq name="query.date_type" value="5"}class="active"{/eq}><a href="javascript:;" onclick="$('#dateType').val(5);$('#searchForm').submit();">昨日</a></li>
                <li {eq name="query.date_type" value="6"}class="active"{/eq}><a href="javascript:;" onclick="$('#dateType').val(6);$('#searchForm').submit();">上周</a></li>
                <li {eq name="query.date_type" value="7"}class="active"{/eq}><a href="javascript:;" onclick="$('#dateType').val(7);$('#searchForm').submit();">上月</a></li>
                <li {eq name="query.date_type" value="8"}class="active"{/eq}><a href="javascript:;" onclick="$('#dateType').val(8);$('#searchForm').submit();">上年度</a></li>
            </ul>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="50">序号</th>
                    <th>商品名称</th>
                    <th><a href="javascript:;" onclick="sort('total');">总销售量 {eq name="query.sort_field"
                        value="total"}<i class="fa fa-sort-alpha-desc"></i>{/eq}</a></th>
                    <th><a href="javascript:;" onclick="sort('total_price');">总销售额 {eq name="query.sort_field"
                        value="total_price"}<i class="fa fa-sort-alpha-desc"></i>{/eq}</a></th>
                </tr>
                </thead>
                <tbody>
                {volist name="saleTop" id="vo"}
                <tr>
                    <td>{$i}</td>
                    <td>{$vo.goods_name} {$vo.sku_name}</td>
                    <td>{$vo.total}</td>
                    <td>{$vo.total_price}元</td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
    $(function () {
        $('#areaId').change(function () {
            $('#searchForm').submit();
        });
    });
    function sort(field) {
        $("input[name='sort_field']").val(field);
        $('#searchForm').submit();
    }
</script>
{/block}